Skip to content

[deploy-helpers] Warn when a Build Output Preview is missing bindings without IDs - #16752

Draft
edmundhung wants to merge 1 commit into
mainfrom
edmundhung/preview-build-output-missing-bindings
Draft

edmundhung wants to merge 1 commit into
mainfrom
edmundhung/preview-build-output-missing-bindings

Conversation

@edmundhung

Copy link
Copy Markdown
Member

When previewBuildOutput() uploads a Preview, it leaves out KV, D1, and R2 bindings that have no resource ID, so the Preview can get them from the Preview base config. If the Preview base config doesn't define them either, the Preview runs without them and nothing says so.

For example, a cf project with CACHE: bindings.kv() deploys fine to production, because the namespace is created on the first deploy. But after cf previews deploy, env.CACHE is undefined and the Preview fails at runtime.

This adds a warning after the upload that lists those bindings. It reads the Preview base config first, so bindings defined there aren't reported:

These bindings have no resource ID, so they were left out of this Preview, and the Preview base config doesn't define them either:

  KV  KV Namespace
  R2  R2 Bucket

Code that uses these bindings will fail in the Preview. Set a resource ID on these bindings for Previews, or add them to the Preview base config.

The existing missing-bindings warning only runs outside JSON mode, and cf always calls previewBuildOutput() with json: true. This one is logged in both modes. It goes through logger.warn to stderr, so the JSON output stays unchanged. If the Preview base config can't be retrieved, the deployment is already live, so the command still succeeds and the warning lists the bindings it couldn't check (the same approach #16090 takes for the existing warning).


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this adds a CLI warning and doesn't change any documented behavior.

@changeset-bot

changeset-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 637bbaa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudflare/deploy-helpers Patch
@cloudflare/remote-bindings Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 6, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@16752

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@16752

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@16752

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@16752

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@16752

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@16752

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@16752

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@16752

miniflare

npm i https://pkg.pr.new/miniflare@16752

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@16752

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@16752

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@16752

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@16752

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@16752

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@16752

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@16752

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@16752

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@16752

wrangler

npm i https://pkg.pr.new/wrangler@16752

commit: 637bbaa

@ask-bonk

ask-bonk Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

@edmundhung Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

1 participant